DISASM ORG $B000 DISASSEMBLER FOR THE MCS-6502
   ;
   ; VERSION 1.0 MARCH 82
   ;
   ; ZERO PAGE DEFINES
   ;
PRTFLG * $00EE ; PRINTER FLAG
FORMAT * $00EF ;
LENGTH * FORMAT +01
LMNEM * LENGTH +01
RMNEM * LMNEM +01
COUNT * RMNEM +03
YSAVE * COUNT +01
PCL * YSAVE +04
PCH * PCL +01
STRPTL * $00EA ;
STRPTH * $00EB ;
TEMP * $00FC ;
CHAR * $00EF ;
   ;
   ; PIA ADDRESSES
   ;
PIAAD * $1700 ; PIA A DATA 
PIAADD * $1701 ; PIA A DATA DIR
PIABD * $1702 ; PIA B DATA
PIABDD * $1703 ; PIA B DATA DIR
   ;
   ;     SUBROUTINES IN KIM-1
   ;
MONIT * $1C4F ;
OUTCHK * $1EA0 ;
   ;
   ; CONSTANTS
   ;
FF * $0C ;
BL * $20 ;
CR * $0D ;
LF * $0A ;
BS * $08 ;
CANCEL * $18 ;
   ;
   ; MAIN PROGRAM INITITIALISTAION
   ;
START CLD  ;
 LDXIM $FF ; INIT STACK
 TXS  ;
 LDAIM $01 ; FIRST PAGE
 STA PAGECT ;
 LDAIM $00 ;
 STA PRTFLG ;
 STA LINECT ; LINE := 0
 LDAIM FF ;
 JSR OUTCHK ; FORMFEED ON VIDEO
 JSR WAITN ;
 JSR CRLF ;
 LDXIM GRTMSG ; PRINT 'DISASSEMBLER 6502'
 LDYIM GRTMSG /
 JSR PRTSTR ;
 JSR CRLF ;
 JSR CRLF ;
 LDXIM PRTMSG ; PRINT 'PRINTER OR VIDEO (P/V) ?'
 LDYIM PRTMSG /
 JSR PRTSTR ;
 JSR BUFIN ;  ASK FOR INPUT
 LDXIM $00 ;
 LDAAX BUFFER ;
 CMPIM 'P ; ANSWER IS 'Y' ?
 BNE NOPRT ;
 JSR INITPR ;
 LDAIM $01 ;
 STA PRTFLG ;
NOPRT JSR CRLF ;
ADR LDXIM STADRM ; PRINT STARTADDRES
 LDYIM STADRM /
 JSR PRTSTR ;
 JSR BUFIN ;
 LDXIM $00 ;
 JSR GETADR ;
 LDA POINTH ;
 STA BEGADH ;
 LDA POINTL ;
 STA BEGADL ;
NEXTCH LDAAX BUFFER ;
 CMPIM '  ; BLANK IS DELIMITER
 BEQ SKIP ;
 CMPIM ', ;
 BEQ SKIP ; ',' IS DELIMITER
 CMPIM '- ; '-' IS DELIMITER
 BNE ENDA ; MAYBE NUMBER
SKIP INX  ; SKIP DELIMITER
 JMP NEXTCH ;
ENDA JSR GETADR ;
 CPXIM $02 ;
 BCC NOPRT ; NOT RIGHT INPUT
 LDA BEGADH ; IS BEGINADR < ENDADR ?
 CMP POINTH ;
 BCC OK ;
 BEQ LOWCH ;
 BNE NOPRT ; NO TRY AGAIN
LOWCH LDA POINTL ;
 CMP BEGADL ;
 BCC NOPRT ;
   ;
   ; GET HEADER
   ;
OK LDA PRTFLG ; IF PRINTER THEN AK FOR HEADER
 BEQ DIS ;
 JSR CRLF ;
 LDXIM HEAMSG ;
 LDYIM HEAMSG / PRINT 'HEADER'
 JSR PRTSTR ;
 JSR BUFIN ;
 LDXIM $FF ;
NEXTB INX  ;
 LDAAX BUFFER ;
 CMPIM CR ; SCAN BUFFER TO CR
 BNE NEXTB ;
 LDAIM BL ; REPLACE WITH BLANK
NEXTBL STAAX BUFFER ;
 INX  ;
 CPXIM $3F ;
 BNE NEXTBL ;
 LDAIM $A0 ; MAKE LAST END OF STRING
 STAAX BUFFER ;
   ;
   ; START DISASSEMBLY
   ;
DIS LDA BEGADL ;
 STA PCL ;
 LDA BEGADH ;
 STA PCH ;
FURDER JSR INSTDS ; DISASSEMBLE INSTRUCTION
 JSR PCADJ ; NEXT ADDRESS
 STA PCL ;
 STY PCH ;
 CPY POINTH ;
 BNE FURDER ;
 CMP POINTL ;
 BCC FURDER ;
 JSR CRLF ;
 LDAIM FF ;
 JSR OUTCH ;
 LDAIM $00 ;
 STA PRTFLG ;
 LDAIM START ; SET UP START ADDRESS
 STA PCL ;
 LDAIM START /
 STA PCH ;
 JMP MONIT ; BACK TO MONITOR
   ;
   ; SUBROUTINES FOLLOW :
   ;     DISASSEMBLE ONE INSTRUCTION
   ;
INSTDS JSR PRPC ; PRINT PCLPCH
 LDAIX PCL ; GET OPCODE
 TAY  ;
 LSRA  ; EVEN/ODD TEST
 BCC IEVEN ;
 LSRA  ; TEST B1
 BCS ERR ; XXXXXX11 INSTRUCTION INVALID
 CMPIM $22 ;
 BEQ ERR ; 10001001 INSTRUCTION INVALID
 ANDIM $07 ; MASK 3 BITS FOR ADDR MODE
 ORAIM $80 ; ADD INDEXING OFFSET
IEVEN LSRA  ; LSB INTO CARRY FOR
 TAX  ; LEFT/RIGHT TEST BELOW
 LDAAX MODE ; INDEX INTO ADDRESSING MODE TABLE
 BCS RTMODE ; IF CARRY SET USE LSD FOR
 LSRA  ; PRINT FORMAT INDEX
 LSRA  ;
 LSRA  ; IF CARRY CLEAR USE MSD
 LSRA  ;
RTMODE ANDIM $0F ; MASK FOR 4-BIT INDEX
 BNE GETFMT ; 0 FOR INVALID OPCODES
ERR LDYIM $80 ; SUBSTITUTE $80 FOR INVALID OPCD.
 LDAIM $00 ; SET PRINT FORMAT INDEX TO 0
GETFMT TAX  ;
 LDAAX MODEB ; INDEX INTO PRINT FORMAT TABLE
 STA FORMAT ; SAVE FOR ADDR.FIELD FORMAT
 ANDIM $03 ; MASK 2-BIT LENGTH. 0=1-BYTE
 STA LENGTH ; 1=2 BYTE, 2=3 BYTE
 TYA  ; OPCODE
 ANDIM $8F ; MASK IT FOR 1XXX1010 TEST
 TAX  ; SAVE IT
 TYA  ; OPCODE AGAIN TO A
 LDYIM $03 ;
 CPXIM $8A ;
 BEQ MNNDXC ;
MNNDXA LSRA  ;
 BCC MNNDXC ; FORM INDEX INTO MNEMONIC TABLE
 LSRA  ;
MNNDXB LSRA  ; 1XXX1010 => 00101XXX
 ORAIM $20 ; XXXYYY01 => 00111XXX
 DEY  ; XXXYYY10 => 00110XXX
 BNE MNNDXB ; XXXYY100 => 00100XXX
 INY  ; XXXXX000 => 000XXXXX
MNNDXC DEY  ;
 BNE MNNDXA ;
 PHA  ; SAVE MNEMONIC TABLE INDEX
PROP LDAIY PCL ;
 JSR PRBYTE ;
 LDXIM $01 ;
PROPBL JSR PRBLB ;
 CPY LENGTH ; PRINT INSTR (1 TO 3 BYTES)
 INY  ; IN A 12-CHARACTER FIELD
 BCC PROP ;
 LDXIM $03 ; CHAR COUNT FOR PRINTING MNEMONIC
 CPYIM $04 ;
 BCC PROPBL ;
 PLA  ; RECOVER MNEMONIC INDEX
 TAY  ;
 LDAAY MNEML ;
 STA LMNEM ; FETCH 3-CHAR MNEMONIC
 LDAAY MNEMR ; PACKED IN 2 BYTES
 STA RMNEM ;
PRMNA LDAIM $00 ;
 LDYIM $05 ;
PRMNB ASL RMNEM ;
 ROL LMNEM ; SHIFT 5 BITS OF CHAR IN ACCU
 ROLA  ; CLEARS CARRY
 DEY  ;
 BNE PRMNB ;
 ADCIM $BF ; ADD 'X' OFFSET
 JSR OUTCH ;  OUTPUT A CHAR OF MNEMONIC
 DEX  ;
 BNE PRMNA ;
 JSR PRBLNK ; OUTPUT 1 BLANK
 LDXIM $06 ; COUNT FOR 6 PRINT-FORMAT BITS
PRADRA CPXIM $03 ;
 BNE PRADRC ; IF X=3 PRINT ADD VALUE
 LDY LENGTH ;
 BEQ PRADRC ; NO PRINT IF LENGTH = 0
PRADRB LDA FORMAT ;
 CMPIM $E8 ; HANDLE REL ADDRESSING MODE
 LDAIY PCL ; SPECIAL (PRINT TARGET ADDRESS)
 BCS RELADR ; (NOT DISPLACEMENT)
 JSR PRBYTE ; OUTPUT 1- OR 2-BYTE ADDRESS
 DEY  ; MOST SIGNIFICANT BYTE FIRST
 BNE PRADRB ;
PRADRC ASL FORMAT ; TEST NEXT PRINT FORMAT BIT
 BCC PRADRD ; IF 0, DON'T PRINT
 LDAAX CHARA -01 ; CORRESPONDING CHARACTER
 JSR OUTCH ;  OUTPUT 1 OR 2 CHARACTERS
 LDAAX CHARB -01 ; (IF CHAR FROM CHARB IS 0)
 BEQ PRADRD ; DON'T OUTPUT IT
 JSR OUTCH ;
PRADRD DEX  ;
 BNE PRADRA ;
 RTS  ; RETURN IF 6 FORMAT BITS
RELADR JSR PCADJB ; PCL, PCH + DISPL + 1 TO A,Y
 TAX  ;
 INX  ;
 BNE PRNTYX ; +1 TO X,Y
 INY  ;
PRNTYX TYA  ;
PRNTAX JSR PRBYTE ; PRINT TARGET ADDRESS OF BRANCH
PRNTX TXA  ; AND RETURN
 JMP PRBYTE ;
PRPC LDAIM $8D ;
 JSR LFCR ; OUTPUT CARRIAGE RETURN
 LDA PCH ;
 LDX PCL ;
 JSR PRNTAX ; OUTPUT PCH AND PCL
 LDAIM $20 ;
 JSR OUTCH ;
PRBLNK LDXIM $01 ; BLANK COUNT
PRBLB LDAIM '  ;
PRBLC JSR OUTCH ;  OUTPUT A BLANK
 DEX  ;
 BNE PRBLB ; LOOP UNTIL COUNT IS ZERO
 RTS  ;
PCADJ LDA LENGTH ; 0=1 BYTE, 1=2 BYTE, 2=3 BYTE
PCADJB SEC  ;
PCADJC LDY PCH ;
 TAX  ; TEST DISPLACEMENT SIGN FOR REL.
 BPL PCADJD ; ADDRESSING MODE
 DEY  ; EXTEND NEG BY DECREMENTING PCH
PCADJD ADC PCL ;
 BCC RTSA ; PCL+LENGTH (OR DISPLACEMENT) +1 
 INY  ;
RTSA RTS  ;
   ;
   ; DISASSEMBLER TABLES
   ;
MODE = $40 ;
 = $02
 = $45
 = $03
 = $D0
 = $08
 = $40
 = $09
 = $30 ; XXXXXXZ0 INSTRUCTIONS
 = $22
 = $45 ; Z=0, LEFT  NIBBLE
 = $33 ; Z=1, RIGHT NIBBLE
 = $D0
 = $08
 = $40
 = $09
 = $40
 = $02
 = $45
 = $33
 = $D0
 = $08
 = $40
 = $09
 = $40
 = $02
 = $45
 = $B3
 = $D0
 = $08
 = $40
 = $09
 = $00
 = $22
 = $44
 = $33
 = $D0
 = $8C
 = $44
 = $00
 = $11
 = $22
 = $44
 = $33
 = $D0
 = $8C
 = $44
 = $9A
 = $10
 = $22
 = $44
 = $33
 = $D0
 = $08
 = $40
 = $09
 = $10
 = $22
 = $44
 = $33
 = $D0
 = $08
 = $40
 = $09
 = $62
 = $13 ; YYXXXZ01 INSTRUCTIONS
 = $78
 = $A9
MODEB = $00 ; ERROR
 = $21 ; IMMEDIATE
 = $81 ; ZERO PAGE
 = $82 ; ABSOLUTE
 = $00 ; IMPLIED
 = $00 ; ACCUMULATOR
 = $59 ; INDEXED INDIRECT
 = $4D ; INDIRECT INDEXED
 = $91 ; ZEROPAGE INDEXED BY REGISTER X
 = $92 ; ABSOLUTE INDEXED BY REGISTER X
 = $86 ; ABSOLUTE INDEXED BY REGISTER Y
 = $4A ; ABSOLUTE
 = $85 ; ZEROPAGE INDEXED BY REGISTER Y
 = $9D ; RELOCATABLE
CHARA = ',
 = ')
 = ',
 = '#
 = '(
 = '$
CHARB = 'Y
 = $00
 = 'X
 = '$
 = '$
 = $00
MNEML = $1C ; XXXXX000 INSTRUCTIONS
 = $8A
 = $1C
 = $23
 = $5D
 = $8B
 = $1B
 = $A1
 = $9D
 = $8A
 = $1D
 = $23
 = $9D
 = $8B
 = $1D
 = $A1
 = $00
 = $29
 = $19
 = $AE
 = $69
 = $A8
 = $19
 = $23
 = $24
 = $53
 = $1B
 = $23
 = $24
 = $53
 = $19
 = $A1
 = $00 ; XXXYY100 INSTRUCTIONS
 = $1A
 = $5B
 = $5B
 = $A5
 = $69
 = $24
 = $24
 = $AE ; 1XXX1010 INSTRUCTIONS
 = $AE
 = $A8
 = $AD
 = $29
 = $00
 = $7C
 = $00
 = $15 ; XXXYYY10 INSTRUCTIONS
 = $9C
 = $6D
 = $9C
 = $A5
 = $69
 = $29
 = $53
 = $84 ; XXXYYY01 INSTRUCTIONS
 = $13
 = $34
 = $11
 = $A5
 = $69
 = $23
 = $A0
MNEMR = $D8 ; XXXXX000 INSTRUCTIONS
 = $62
 = $5A
 = $48
 = $26
 = $62
 = $94
 = $88
 = $54
 = $44
 = $C8
 = $54 
 = $68
 = $44
 = $E8
 = $94 
 = $00
 = $B4
 = $08
 = $84
 = $74
 = $B4
 = $28
 = $6E
 = $74
 = $F4
 = $CC
 = $4A
 = $72
 = $F2
 = $A4
 = $8A
 = $00 ; XXXYY100 INSTRUCTIONS
 = $AA
 = $A2
 = $A2
 = $74
 = $74
 = $74
 = $72
 = $44 ; 1XXX1010 INSTRUCTIONS
 = $68
 = $B2
 = $32
 = $B2
 = $00
 = $22
 = $00
 = $1A ; XXXYYY10 INSTRUCTIONS
 = $1A
 = $26
 = $26
 = $72
 = $72
 = $88
 = $C8
 = $C4 ; XXXYYY01 ISTRUCTIONS
 = $CA
 = $26
 = $48
 = $44
 = $44
 = $A2
 = $C8
   ;
   ; LFCR ROUTINE FOR DISASSEMBLY, CONTROL LAYOUT
   ;
LFCR LDA PRTFLG ;
 BEQ VID ;
 LDA LINECT ;
 BNE NOH ; IF LINECT = 0 THEN
 JSR PRINTH ;   PRINT HEADER
 SED  ; 
 LDA PAGECT ;
 CLC  ;
 ADCIM $01 ; PAGECT := PAGECT + 1
 STA PAGECT ;
 CLD  ;
NOH INC LINECT ;
 LDA LINECT ; IF LINECT = 55 THEN
 CMPIM $37 ;   LINECT := 0
 BNE NOTEND ;
 LDAIM $00 ;
 STA LINECT ;
NOTEND JMP DOCRLF ;
VID LDA LINECT ; ELSE
 CMPIM $14 ;   IF LINECT = 20 THEN
 BNE NOPAGE ;
 JSR INKEYB ;  GETKEY
 CMPIM CR ;   IF KEY = CR THEN
 BNE NOSTOP ;
 LDA POINTL ; BEGIN ADR := END ADDRESS
 STA PCL ;
 LDA POINTH ;
 STA PCH ;
NOSTOP LDAIM $01 ;
 STA LINECT ;
 JMP DOCRLF ;
NOPAGE INC LINECT ;
DOCRLF JSR CRLF ;
 RTS  ;
   ;
   ; PRINT HEADER
   ;
PRINTH JSR CRLF ;
 LDAIM FF ;
 JSR OUTCH ;
 LDXIM BUFFER ; PRINT HEADER FROM BUFFER
 LDYIM BUFFER /
 JSR PRTSTR ;
 LDXIM PAGMSG ; PRINT 'PAGE'
 LDYIM PAGMSG /
 JSR PRTSTR ;
 LDA PAGECT ;
 JSR PRBYTE ;
 JSR CRLF ;
 JSR CRLF ;
 JSR CRLF ;
 RTS  ;
   ;
   ; CARRIAGE RETURN LINEFEED
   ;
CRLF LDAIM CR ;
 JSR OUTCH ;
 LDAIM LF ;
 JSR OUTCH ;
 JSR WAITN ;
 RTS  ;
   ;
   ; WAIT 1 MS
   ;
WAITN LDXIM $14 ;
XDEL LDYIM $0A ;
YDEL DEY  ;
 BNE YDEL ;
 DEX  ;
 BNE XDEL ;
 RTS  ;
   ;
   ; PRINT BYTE IN A AS TWO ASCII
   ;
PRBYTE STY YSAVE ;
 STA TEMP ;
 LSRA  ;
 LSRA  ; LEFT NIBBLE FIRST
 LSRA  ;
 LSRA  ;
 JSR HEXTA ;
 LDA TEMP ;
 JSR HEXTA ;	
 LDA TEMP ;
 LDY YSAVE ;
 RTS  ;
   ;
HEXTA ANDIM $0F ;
 CMPIM $0A ;
 CLC  ;
 BMI HEXTAI ;
 ADCIM $07 ;
HEXTAI ADCIM $30 ;
 JMP OUTCH ;
   ;
   ;
    PRINTER OUTPUT H14 MET HANDSHAKE
   ;
   ;
OUTPR PHP  ; SAVE REGISTERS ON STACK
 PHA  ;
 TYA  ;
 PHA  ;
 TXA  ;
 PHA  ;
 LDA CHAR ;
 PHA  ;
 TSX  ;
 LDAAX $0104 ;
 STA CHAR ;
BUFFV LDA PIABD ; PRINTER RTS
 ANDIM $02 ; IN BIT 2
 BEQ BUFFV ; PRINTER READY ?
 LDA PIABD ;
 ORAIM $01 ; STARTBIT
 STA PIABD ;
 JSR TDELAY ;
 LDXIM $08 ; 8 BITS TO SEND 
 BPL VOLGB ; DUMMY
VOLGB LDA PIABD ;
 LSR CHAR ; LSB IN CARRY
 BCS EEN ;
 ORAIM $01 ; BIT IS 0
 BCC BUIT ;
 NOP  ; TIMING
EEN ANDIM $FE ; BIT IS 1
BUIT STA PIABD ;
 JSR TDELAY ;
 DEX  ; NEXT BIT
 BNE VOLGB ;
 LDA PIABD ;
 ANDIM $FE ; STOPBIT
 NOP  ;
 NOP  ;
 NOP  ; TIMING
 BPL DUMM ;
DUMM STA PIABD ;
 JSR TDELAY ;
 PLA  ;
 STA CHAR ;
 PLA  ;
 TAX  ;
 PLA  ;
 TAY  ;
 PLA  ;
 PLP  ;
 RTS  ;
   ;
    DELAY ROUTINE 4800 BAUD
   ;
TDELAY LDYIM $22 ;
DLOOP DEY  ;
 BNE DLOOP ;
 NOP  ;
 RTS  ;
   ;
   ; INIT PRINTER = 96 CHARACTERS
   ;
INITPR LDA PIABDD ;
 ORAIM $01 ;
 ANDIM $7D ;
 STA PIABDD ; PORT PRINTER
 LDAIM $00 ; DUMMY START CHARACTER
 JSR OUTPR ;
 LDAIM $1B ; ESCAPE
 JSR OUTPR ;
 LDAIM $75 ; 96 CHARACTERS SEQUENCE
 JSR OUTPR ;
 LDAIM $10 ;
 JSR OUTPR ;
 RTS  ;
   ;
   ; PARALLEL INPUT KEYBOARD
   ;
INKEYB BIT PIAAD ; STROBE IS BIT 7 
 BPL INKEYB ;
STROBE BIT PIAAD ; END OF STROBE ?
 BMI STROBE ;
 LDA PIAAD ;
 RTS  ;
   ;
   ; PRINT CHARACTER ON VIDEO
   ;
OUTVID PHA  ; PUSH REGISTERS ON STACK
 TYA  ;
 PHA  ;
 TXA  ;
 PHA  ;
 TSX  ;
 LDAAX $0103 ; RESTORE ACCUMULATOR
 CMPIM FF ;
 BEQ NOFF ; REMOVE FORM FEED FROM VIDEO
 JSR OUTCHK ; PRINT ACCU
NOFF PLA  ;
 TAX  ;
 PLA  ;
 TAY  ;
 PLA  ; RESTORE REGISTERS
 RTS  ;
   ;
   ; PROCEDURE OUTCHARACTER
   ;
OUTCH PHA  ;
 LDA PRTFLG ; IF PRINTER THEN
 BEQ NOPNT ;   OUTPRINTER
 PLA  ;
 JSR OUTPR ;
 JSR OUTVID ;
 RTS  ;
NOPNT PLA  ;
 JSR OUTVID ;
 RTS  ;
   ;
   ; OUTSTRING
   ;
PRTSTR STX STRPTL ; PROCEDURE PRINTSTRING
 STY STRPTH ; 
PNEXT LDYIM $00 ; REPEAT
 LDAIY STRPTL ;  PRINT(MEM^(STRINGPTR))
 PHA  ;  STRINGPTR := STRINGPTR + 1
 JSR OUTCH ; UNTIL END OF STRING
 PLA  ;
 BMI LAST ;
 INC STRPTL ;
 BNE NEXTS ;
 INC STRPTH ;
NEXTS JMP PNEXT ;
LAST RTS  ;
   ;
   ; GET LINE IN BUFFER
   ;
BUFIN LDYIM $00 ; BUFFER POINTER := 0
INB JSR INKEYB ; GET CHARACTER INPUT
 CMPIM '  ; CONTROL CHARACTER ?
 BCC CONTROL ;
 JSR OUTCH ; ECHO CHARACTER
 STAAY BUFFER ; STORE CHARACTER
 INY  ;
 CPYIM $3F ; NOT MORE THEN 64 CHARACTERS
 BMI INB ; GO ON
 DEY  ; 
 JMP INB ; NO ACTION
CONTROL CMPIM BS ; BACKSPACE ?
 BNE DELETE ;
 JSR OUTCH ; ECHO BACKSPACE
 LDAIM BL ; 
 JSR OUTCH ;
 LDAIM BS ;
 JSR OUTCH ;
 DEY  ; ONE PLACE BACK
NEXTY BPL INB ;
 INY  ; TOO FAR BACK
 JMP NEXTY ;
DELETE CMPIM CANCEL ; CANCEL ?
 BNE EOLN ;
 JSR CRLF ;
 JMP BUFIN ;
 JSR CRLF ;
EOLN CMPIM CR ; END OF LINE ?
 BNE INB ;
 STAAY BUFFER ;
 JSR CRLF ;
 RTS  ;
   ;
   ; PACK ASCII TO HEX
   ;
ISTHEX CMPIM $30 ; IF A GE 30 AND A LT 3A THEN
 BCC RET ;
 CMPIM $3A ;
 BCS LETTER ;
 BCC SHIFT ;
LETTER CMPIM $41 ; IF A GE $41 AND A LT 47 THEN
 BCC RET ;
 CMPIM $47 ;
 BCS RET ;
 ADCIM $09 ;
SHIFT ANDIM $0F ;
 LDYIM $00 ;
 RTS  ;
RET LDYIM $FF ; NOT HEX, SET Z
 RTS  ;
   ;
   ; GET ADDRESS  FROM BUFFER,X
   ;
GETADR LDAIM $00 ;
 STA POINTL ; CLEAR ADDRESS
 STA POINTH ;
NEXTAD LDAAX BUFFER ;
 JSR ISTHEX ; CHECK IF HEX
 BNE GOTADR ; ELSE READY
 LDYIM $04 ; SHIFT ADDRESS 4 BITS LEFT
SHL ASL POINTL ;
 ROL POINTH ;
 DEY  ;
 BNE SHL ;
 ORA POINTL ; PLACE LS NIBBLE IN ADDRESS
 STA POINTL ;
 INX  ;
 JMP NEXTAD ;
GOTADR RTS  ;
   ;
   ; TABLES
   ;
GRTMSG = 'D
 = 'I
 = 'S
 = 'A
 = 'S
 = 'S
 = 'E
 = 'M
 = 'B
 = 'L
 = 'E
 = 'R
 = '
 = '6
 = '5
 = '0
 = $B2
   ;
PRTMSG = 'P
 = 'R
 = 'I
 = 'N
 = 'T
 = 'E
 = 'R
 = ' 
 = 'O
 = 'R
 = ' 
 = 'V
 = 'I
 = 'D
 = 'E
 = 'O
 = ' 
 = '(
 = 'P
 = '/
 = 'V
 = ')
 = ' 
 = '?
 = $A0 
   ;
STADRM = 'A
 = 'D
 = 'D
 = 'R
 = 'E
 = 'S
 = 'S
 = ' 
 = 'R
 = 'A
 = 'N
 = 'G
 = 'E
 = ' 
 = '=
 = $A0
   ;
PAGMSG = ' 
 = 'P
 = 'A
 = 'G
 = 'E
 = $A0 
   ;
HEAMSG = 'H
 = 'E
 = 'A
 = 'D
 = 'E
 = 'R
 = ' 
 = '=
 = $A0
   ;
PAGECT = $00 ; PAGE COUNTER
LINECT = $00 ; LINE COUNTER
BEGADL = $00 ; BEGINADRES
BEGADH = $00 ;
POINTL = $00 ; ADDRESS POINTER
POINTH = $00 ;
BUFFER = $00 ; INPUT BUFFER 64 CHARACTER
